<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>Insert Data</title>
    <!--适配屏幕大小的-->
    <meta name="viewport" http-equiv="Content-Type" content="width=device-width,initial-scale=1,text/html" charset="UTF-8"/>
    <link rel="stylesheet" href="../static/css/bootstrap.min.css"/>
    <script src="../static/js/jquery-3.3.1.min.js"></script>
    <script src="../static/js/popper.min.js"></script>
    <script src="../static/js/bootstrap.min.js"></script>
    <!--kindeditor-->
    <link rel="stylesheet" href="../static/themes/default/default.css" />
    <script charset="utf-8" src="../static/js/kindeditor-min.js"></script>
    <script charset="utf-8" src="../static/js/zh_CN.js"></script>
    <style>
        #menu{
            position: fixed;
            top: 10px;
        }
        #div1{
            position: absolute;
            top: 10px;
            left: 130px;
        }

    </style>
</head>
<body background="../static/img/3.jpg" style="background-attachment: fixed;background-size: 100%,100%">
    <div class="container" id="menu" >
        <button class="btn btn-primary" id="back">返回</button>
    </div>
    <div class="container" id="div1">
        <div class="card">
            <form id="form1" action="/insertnew" method="post">
                <div id="card-header" class="card-header bg-warning" style="color: #007bff">
                    <input for="comment" placeholder="title..." style="width: 300px" id="input1" name="title" />
                </div>
                <div id="card-body" class="card-body bg-secondary text-white">
                    <textarea id="comment" name="content" placeholder="write something..." style="width:1070px;height:400px;visibility:hidden;"></textarea>
                    <p>
                        <br>
                            <input type="button" name="getHtml" class="btn btn-success" value="保存文档" />
                        </br>
                    </p>
                </div>
            </form>
        </div>
    </div>

<div class="container">
    <button type="button" hidden="hidden" id="chufa" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
        打开模态框
    </button>
    <!--模态框-->
    <div class="modal fade" id="myModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <!--模态框头部-->
                <div class="modal-header">
                    <h4 class="modal-tittle">返回信息</h4>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <!--模态框主体-->
                <div id="modal-body" class="modal-body">

                </div>
                <!--模态框底部-->
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('textarea[name="content"]', {
            allowFileManager : true,
            items: [

            ]
        });
        K('input[name=getHtml]').click(function(e) {
            var params = {};
            params.title = $("#input1").val();
            params.content = editor.html();
            $.ajax({
                type: "post",
                url: "/insertnew",
                dataType: "json",
                data: params,
                async: false,
                success: function(data){
                    $("#modal-body").html(data.msg);
                    $("#chufa").trigger('click');
                    // alert(data.ret_code);
                }
            });


        });

    });

    $("#back").click(function(){
        window.location.href = "/";
    });



</script>
</body>
</html>
